1 00:00:00,420 --> 00:00:06,050 ‫Welcome back, this is just six in the previous letter we wrote this. 2 00:00:06,840 --> 00:00:11,040 ‫We cleaned it up a little bit so that it was able to allow guests to post request. 3 00:00:11,310 --> 00:00:14,940 ‫And we also made sure that the response that we are returning is additionally. 4 00:00:15,180 --> 00:00:16,580 ‫And that made it easy. 5 00:00:16,800 --> 00:00:20,300 ‫That makes it easy for consumption by our front end application. 6 00:00:21,030 --> 00:00:30,090 ‫Now, in this lecture, I want us to send different other things with the response they are getting 7 00:00:30,090 --> 00:00:31,020 ‫from our API. 8 00:00:31,500 --> 00:00:39,540 ‫And what they would like us to do here is to give the user a message like when maybe the response they'll 9 00:00:39,540 --> 00:00:41,550 ‫be successful when it is not successful. 10 00:00:41,850 --> 00:00:49,500 ‫And what they like to do here is I come on the top of my file here and I define two things. 11 00:00:49,890 --> 00:00:52,350 ‫Two to two variables. 12 00:00:53,490 --> 00:01:00,390 ‫One, I called the success and this was of this contains 200 and the other one I call not found. 13 00:01:02,790 --> 00:01:04,920 ‫This one I can give supply four hundred. 14 00:01:05,160 --> 00:01:10,740 ‫And what I am going to do here now is to check whether so I'm going to write a condition. 15 00:01:10,740 --> 00:01:20,460 ‫Sorry, I'm going to read up on this one here that if my items has anything, OK, if my items are saying 16 00:01:20,460 --> 00:01:22,830 ‫that you remember this is only for the purpose of this demo. 17 00:01:23,520 --> 00:01:34,980 ‫If my items has anything, then I want this thing to compose a body to to give it as good as gold equals 18 00:01:35,100 --> 00:01:35,750 ‫success. 19 00:01:35,770 --> 00:01:38,370 ‫You remember the success that we need up there. 20 00:01:39,410 --> 00:01:40,650 ‫Code is going to be success. 21 00:01:41,070 --> 00:01:42,540 ‫This is not not a success. 22 00:01:42,540 --> 00:01:44,040 ‫It is a success. 23 00:01:44,520 --> 00:01:49,020 ‫So it is success, status quo, status good is going to be success. 24 00:01:49,620 --> 00:01:52,470 ‫And then the body that I want to pass are my items. 25 00:01:52,470 --> 00:01:55,200 ‫OK, so I have those two things. 26 00:01:55,200 --> 00:01:56,430 ‫There I am. 27 00:01:56,670 --> 00:02:05,970 ‫Come here and see if this thing is not, then I am going to pass status as quote listed as good. 28 00:02:06,270 --> 00:02:13,140 ‫I'm going to pass here is not found item and then the body here is going to be maybe a string. 29 00:02:13,140 --> 00:02:22,380 ‫Seeing the item you are looking for is not found. 30 00:02:22,500 --> 00:02:25,590 ‫You can again pass whatever kind of message on to pass here. 31 00:02:25,890 --> 00:02:28,650 ‫And then here I have about Devastator scored in all of them. 32 00:02:28,950 --> 00:02:34,470 ‫And then what I'm going to do here next is that I am going not to compose my response. 33 00:02:34,510 --> 00:02:34,890 ‫Right. 34 00:02:36,090 --> 00:02:37,350 ‫And then went to see response. 35 00:02:37,890 --> 00:02:38,910 ‫This is very important. 36 00:02:39,240 --> 00:02:45,390 ‫Response is, of course, additionally, I want to return a dictionary, dict the dictionary and then 37 00:02:45,390 --> 00:02:49,830 ‫within this dictionary, what I want to pass is two things that is listed as good. 38 00:02:51,270 --> 00:02:52,350 ‫Remember, that is what I am doing. 39 00:02:52,350 --> 00:02:58,410 ‫This is so that we can have in status status code. 40 00:02:58,950 --> 00:03:03,000 ‫And then the next thing that I want to pass here is the body and the body I want to pass. 41 00:03:03,000 --> 00:03:04,590 ‫Here is again the body. 42 00:03:06,560 --> 00:03:11,970 ‫And what this thing is going to do is and then, of course, I'm going to return now the response. 43 00:03:11,990 --> 00:03:12,380 ‫All right. 44 00:03:12,860 --> 00:03:14,120 ‫I'm going to return the response. 45 00:03:14,120 --> 00:03:17,040 ‫Instead of returning the items, I'm going to redundant the response. 46 00:03:17,040 --> 00:03:21,540 ‫So what we have done here is we have created two two variables on top of the file. 47 00:03:21,800 --> 00:03:24,560 ‫We have one with 200 and we have one with 400. 48 00:03:24,890 --> 00:03:30,500 ‫And then here we have said if I add them, so if we get items from here, what we're going to do is 49 00:03:30,500 --> 00:03:35,140 ‫set the status code for success and then the bodies will to contain our items. 50 00:03:35,600 --> 00:03:40,520 ‫Otherwise, if this is not found, what are you going to do is that we are going to stay the status 51 00:03:40,520 --> 00:03:41,300 ‫quo to not found. 52 00:03:41,420 --> 00:03:44,660 ‫And the what is going to be the item you're looking for is not found. 53 00:03:44,720 --> 00:03:45,040 ‫Right. 54 00:03:45,950 --> 00:03:49,310 ‫And then this is going to make more sense in the next video. 55 00:03:49,310 --> 00:03:54,530 ‫When we come back with the next the next of us, a system where we would be creating with separate parameters. 56 00:03:54,890 --> 00:04:00,820 ‫And then here we we set up our DNA, we compose it, and then we supply this sort of status code. 57 00:04:00,950 --> 00:04:05,660 ‫And the body of what you can call this anything else you want is going to be key and value key and value 58 00:04:05,690 --> 00:04:08,340 ‫in our dictionary in our response. 59 00:04:08,390 --> 00:04:16,430 ‫So when we save that, then come to our when you save that, then come to a postman and send you can 60 00:04:16,430 --> 00:04:18,400 ‫see, you know, the message has changed a little. 61 00:04:18,680 --> 00:04:25,430 ‫We have this code of 200 on the body that we are getting here is our our our items. 62 00:04:25,430 --> 00:04:29,020 ‫So if we add more than one item, you could see them here. 63 00:04:29,030 --> 00:04:34,520 ‫So you're going to see what is going to be happening here as we move on with this tutorial. 64 00:04:35,050 --> 00:04:39,810 ‫With this, you're going to see what is going to be happening here when we move on with this series. 65 00:04:39,830 --> 00:04:43,100 ‫Thank you so much and see you in the next lecture.